package com.cx.contentcenter.service.impl;

import com.cx.contentcenter.entity.MidUserShare;
import com.cx.contentcenter.dao.MidUserShareDao;
import com.cx.contentcenter.service.MidUserShareService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MidUserShare)表服务实现类
 *
 * @author ThinkPad
 * @since 2021-09-09 14:58:53
 */
@Service("midUserShareService")
public class MidUserShareServiceImpl implements MidUserShareService {
    @Resource
    private MidUserShareDao midUserShareDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public MidUserShare queryById(Integer id) {
        return this.midUserShareDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<MidUserShare> queryAllByLimit(int offset, int limit) {
        return this.midUserShareDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param midUserShare 实例对象
     * @return 实例对象
     */
    @Override
    public MidUserShare insert(MidUserShare midUserShare) {
        this.midUserShareDao.insert(midUserShare);
        return midUserShare;
    }

    /**
     * 修改数据
     *
     * @param midUserShare 实例对象
     * @return 实例对象
     */
    @Override
    public MidUserShare update(MidUserShare midUserShare) {
        this.midUserShareDao.update(midUserShare);
        return this.queryById(midUserShare.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.midUserShareDao.deleteById(id) > 0;
    }
}